package org.test.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.test.mapper.IUserMapper;
import org.test.model.User;
import org.test.service.IUserService;

import com.alibaba.druid.util.StringUtils;

@Service
public class UserServiceImpl implements IUserService{

	@Autowired
	IUserMapper userMapper;
	
	@Override
	public boolean updateUser(User user) {
		int result = userMapper.updateUser(user);
		if(result == 0){
			return false;
		}else{
			return true;
		}
	}

	@Override
	public boolean registerUser(User user) {
		int result = userMapper.insertUser(user);
		if(result == 0){
			return false;
		}else{
			return true;
		}
	}

	@Override
	public User findUserByUserId(Integer userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User findUserByAccount(String account) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User findUser(User user) {
		return userMapper.findUser(user);
	}

	@Override
	public User findUserByAccountAndPwd(String userAccount, String pwd) {
		if(!StringUtils.isEmpty(userAccount) && !StringUtils.isEmpty(pwd)){
			User paramUser = new User();
			paramUser.setUserAccount(userAccount);
			paramUser.setPwd(pwd);
			return userMapper.findUser(paramUser);
		}
		return null;
	}

	@Override
	public boolean updateUserPassWord(User user) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public List<User> findUserList() {
		return userMapper.findUserList();
	}

}
